<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li class="select-time">
								<label>上传时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								状态：<select name="status">
									<option value="">所有</option>
									<option value="0">启用</option>
									<option value="2">禁用</option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	         <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:merchantFeedback:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:merchantFeedback:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:merchantFeedback:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:merchantFeedback:remove')}]];
        var prefix = ctx + "system/merchantFeedback";

        $(function() {
            var options = {
                url: prefix + "/materialList",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                detailUrl: prefix + "/detail/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "物料图片",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '主键id',
					visible: false
				},
				{
					field : 'merchantName', 
					title : '作者',
					sortable: true
				},
				{
					field : 'content', 
					title : '文字内容',
					formatter: function(value, row, index) {
						 if(value != null && value.length>50){
			            		return value.substr(0,50)+"......."
			            	} else {
			            		return value;
			            	}
			            }
				},
				{
					field : 'imgUrl', 
					title : '图片',
					  formatter: function(value, row, index) {
						  if(value != null && value != ""){
							  var array =  value.split(";");
							  var imgStr = "";
							  $.each(array, function(i,v) {
								  imgStr += "<a href='"+v+"'><img width='50'height='50' src='"+v+"'></a>  ";
		    					});
								return imgStr;
						  } else {
							  return "";
						  }
						
			            }
				},
				{
					field : 'createTime', 
					title : '上传时间',
					sortable: true
				},
				 {
		        	visible: editFlag == 'hidden' ? false : true,
		        	title: '使用状态',
		        	align: 'center',
		        	formatter: function (value, row, index) {
		        		return statusTools(row);
		        	}
		        }/* ,
				
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + '" href="#" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-detail"></i>查看详情</a>');
                        return actions.join('');
		            }
		        } */]
            };
            $.table.init(options);
        });

		/* 用户状态显示 */
		function statusTools(row) {
		    if (row.status == 2) {//禁用
    			return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
    		} else {
    			return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
    		}
		}
		
		/* 用户管理-停用 */
		function disable(id) {
			$.modal.confirm("确认要停用该物料吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "id": id, "status": 2 });
		    })
		}

		/* 用户管理启用 */
		function enable(id) {
			$.modal.confirm("确认要启用该物料吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "id": id, "status": 0 });
		    })
		}
    </script>
</body>
</html>